AddElement
Adds a paragraph or a table or a blockLvl content control using its position in the cell.
Syntax
expression.AddElement(oCell, nPos, oElement);
expression
- A variable that represents a ApiTable class.
Parameters
Name | Required/Optional | Data type | Default | Description |
---|---|---|---|---|
oCell | Required | ApiTableCell | The cell where the specified element will be added. | |
nPos | Required | number | The position in the cell where the specified element will be added. | |
oElement | Required | DocumentElement | The document element which will be added at the current position. |
Returns
This method doesn't return any data.
Example
This example adds a paragraph using its position in the cell.
let doc = Api.GetDocument();
let tableStyle = doc.CreateStyle("CustomTableStyle", "table");
tableStyle.SetBasedOn(doc.GetStyle("Bordered"));
let table = Api.CreateTable(3, 3);
table.SetWidth("percent", 100);
table.SetStyle(tableStyle);
doc.Push(table);
let paragraph = Api.CreateParagraph();
paragraph.AddText("This is just a sample text in the first cell.");
let cell = table.GetCell(0, 0);
table.AddElement(cell, 0, paragraph);